<?php

include '../functions.php';
// 索引数组

$arr = [23,2,2,2,2,2,2,2];

// $arr[]=90;

// echo $arr[8][1]

$sum =0;

// for ($i=0; $i < count($arr); $i++) { 
// 	$sum+=$arr[$i];
// }
// 遍历数组

foreach ($arr as $k => $v) {
	$sum  +=$v;
}




var_dump($sum);



$arr = array(345,4,543,5,4,534,345);


$arr[80]=1000;


var_dump($arr);

// 关联数组
$arr = ['name'=>['first'=>'学','last'=>'并思'],'age'=>'18','sex'=>'男'];


var_dump($arr['name']['last']);



foreach ($arr as $k => $v) {
	var_dump($v);
}


$tempArr = [];


for ($i=0; $i <10 ; $i++) { 
	$data['name'] = "小明".$i;
	$data['age'] = '18'.$i;
	$data['sex'] = '男'.$i;
	$tempArr[]= $data;
}

 var_dump($tempArr);

 ?>
 <!doctype html>
 <html lang="en">
 <head>
 	<meta charset="UTF-8">
 	<title>Document</title>
 </head>
 <body>
 	<table border="1">
 		<tr>
 			<td>id</td>
 			<td>姓名</td>
 			<td>年龄</td>
 			<td>性别</td>
 		</tr>
 		<?php foreach ($tempArr as $k => $v) { ?>

 		<tr>
 			<td><?php echo $k; ?></td>
 			<td><?php echo $v['name']; ?></td>
 			<td><?php echo $v['age']; ?></td>
 			<td><?php echo $v['sex']; ?></td>
 		</tr>
 			
 		<?php } ?>
 		
 	</table>
 </body>
 </html>